﻿using MediatR;
using System;
using System.Collections.Generic;
using System.Text;

namespace Casamiel.Domain.Seedwork
{
    /// <summary>
    /// 
    /// </summary>
    public abstract class Entity
    {
       

        private List<INotification> _domainEvents;
        public IReadOnlyCollection<INotification> DomainEvents => _domainEvents?.AsReadOnly();

        public void AddDomainEvent(INotification eventItem)
        {
            _domainEvents = _domainEvents ?? new List<INotification>();
            _domainEvents.Add(eventItem);
        }

        public void RemoveDomainEvent(INotification eventItem)
        {
            _domainEvents?.Remove(eventItem);
        }

        public void ClearDomainEvents()
        {
            _domainEvents?.Clear();
        }
        
    }
    }
